using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace QuanLyKhachHang.DAO
{
	#region using
	using System.Data;
	using QuanLyKhachHang.DTO;
	#endregion
	public class CS_UUDAIDAO : AbstractDAO
	{
		public CS_UUDAIDAO(String strPath): base(strPath)
		{
		}

		~CS_UUDAIDAO()
		{
			base.Dispose();
		}

		public DataSet SelectAll()
		{
			DataSet ds;
			try
			{
				ds = new DataSet();
				base.sql = "usp_CS_UUDAI_SelectAll";
				base.FillDataSet(ref ds, "CS_UUDAI");
				return ds;
			}
			catch(System.Exception e)
			{
				throw new Exception(e.Message, e.InnerException);
			}
			finally
			{
				base.CleanUpObject();
			}
		}

		public DataSet SelectByID(string loai)
		{
			DataSet ds;
			try
			{
				ds = new DataSet();
				base.sql = "usp_CS_UUDAI_SelectByID";
				base.InitializeCommand();
				base.AddParameter("@LOAI", SqlDbType.NVarChar, 100, loai);
				base.FillDataSet(ref ds, "CS_UUDAI");
				return ds;
			}
			catch(System.Exception e)
			{
				throw new Exception(e.Message, e.InnerException);
			}
			finally
			{
				base.CleanUpObject();
			}
		}

		public bool Insert(CS_UUDAIDTO obj)
		{
			try
			{
				base.sql = "usp_CS_UUDAI_Insert";
				base.InitializeCommand();
				base.AddParameter("@LOAI", SqlDbType.NVarChar, 100, obj.LOAI);
				base.AddParameter("@PHANTRAM", SqlDbType.Int, 100, obj.PHANTRAM);
				base.AddParameter("@DIENGIAI", SqlDbType.NVarChar, 100, obj.DIENGIAI);
				return ExecuteStoredProcedure();
			}
			catch
			{
				return false;
			}
		}

		public bool Delete(string loai)
		{
			try
			{
				base.sql = "usp_CS_UUDAI_Delete";
				base.InitializeCommand();
				base.AddParameter("@LOAI", SqlDbType.NVarChar, 100, loai);
				return ExecuteStoredProcedure();
			}
			catch
			{
				return false;
			}
		}

		public bool Update(CS_UUDAIDTO obj)
		{
			try
			{
				base.sql = "usp_CS_UUDAI_Update";
				base.InitializeCommand();
				base.AddParameter("@LOAI", SqlDbType.NVarChar, 100, obj.LOAI);
				base.AddParameter("@PHANTRAM", SqlDbType.Int, 100, obj.PHANTRAM);
				base.AddParameter("@DIENGIAI", SqlDbType.NVarChar, 100, obj.DIENGIAI);
				return ExecuteStoredProcedure();
			}
			catch
			{
				return false;
			}
		}

	}
}